package vno.sci.window
{
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.events.Event;
	
	import org.aswing.ASFont;
	import org.aswing.AsWingManager;
	import org.aswing.JFrame;
	import org.aswing.JTextArea;
	import org.aswing.JTextField;
	import org.aswing.event.FrameEvent;
	
	import vno.sci.event.MonologEvent;
	
	public class SimpleMessageBox extends Sprite
	{
		private var _textPane:JTextArea;
		private var _font:ASFont = new ASFont("",24);
		private var _text:String;
		public var frame:JFrame;
		
		public function SimpleMessageBox(title:String = "", text:String = "", width:int = 300, height:int = 150)
		{
			//initialize AsWing
			AsWingManager.initAsStandard(this);
			//create a JFrame
			_text = text;
			frame = new JFrame(this);
			frame.setSizeWH(width, height);
			frame.setDragable(false);
			frame.setResizable(false);
			frame.setTitle(title);
			_textPane = new JTextArea();
			_textPane.setFont(_font);
			_textPane.setHtmlText(text);
			_textPane.setWordWrap(true);
			_textPane.setEditable(false);
			_textPane.setBorder(null);
			_textPane.getTextField().selectable = false;
			frame.getContentPane().append(_textPane);
			frame.show();
			frame.addEventListener(FrameEvent.FRAME_CLOSING, onClosing);
		}
		
		private function onClosing(event:FrameEvent):void
		{
			dispatchEvent(new MonologEvent(0, MonologEvent.CLOSING));
		}		
		
		public function setFont(f:ASFont):void
		{
			_textPane.setFont(f);
			_textPane.setHtmlText(_text);
		}
	}
}